package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    @AutoFill(value = OperationType.INSERT)
    public void insert(Dish dish);

    /**
     * 菜品分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from sky_take_out.dish where id=#{id}")
    Dish getById(Long id);
    @Delete("delete from sky_take_out.dish where id=#{id}")
    void deleteById(Long id);

    void deleteByIds(List<Long> ids);
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> list(Long categoryId);

    List<Dish> getByIdsAndStatus(List<Long> dishIds,Integer status);

    List<DishVO> getByCategoryId(Long categoryId);

    @Select("select count(id) from sky_take_out.dish where status=#{status}")
    Integer getCountByStatus(Integer status);
}
